package com.blockmeta.bbs.minemodule.adapter;

import android.content.Context;

import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.blockmeta.bbs.baselibrary.base.adapter.BaseAdapter;
import com.blockmeta.bbs.baselibrary.utils.FormatUtil;
import com.blockmeta.bbs.businesslibrary.arouter.RouterHelper;
import com.blockmeta.bbs.businesslibrary.arouter.RouterPath;
import com.blockmeta.bbs.minemodule.R;
import com.blockmeta.bbs.minemodule.pojo.BBSLatestPOJO;
import com.chad.library.adapter.base.BaseViewHolder;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * 意见反馈历史
 */

public class FeedbackHistoryAdapter extends BaseAdapter<BBSLatestPOJO.ListBean, BaseViewHolder> {
    private Context mContext;

    public FeedbackHistoryAdapter(@LayoutRes int layoutResId, @Nullable List<BBSLatestPOJO.ListBean> data, Context context) {
        super(layoutResId, data);
        this.mContext = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, final BBSLatestPOJO.ListBean item) {
        helper.setText(R.id.bbs_item_title, item.getTitle());
        TextView tv_content = helper.getView(R.id.bbs_item_content);
        tv_content.setText(item.getContent());

        ImageView view = helper.getView(R.id.bbs_item_icon);
        Picasso.with(mContext).load(item.getAuthor_info().getAvatar()).placeholder(R.drawable.yoona).into(view);
        //转换时间
        String longToString = FormatUtil.StringDataToString(item.getLastpost() + "");
        helper.setText(R.id.bbs_item_author, item.getAuthor_info().getName() + "/" + longToString);
        helper.setText(R.id.bbs_item_count, item.getReplies() + "");
        LinearLayout view1 = helper.getView(R.id.item_bbs_main);
        view1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                RouterHelper.buildPath(RouterPath.BBS_DETAIL_ACTIVITY)
                        .withString("tid",item.getTid()+"")
                        .navigation(mContext);
            }
        });

    }
}
